﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<form id="form1">
    <div style="padding-top: 20px; margin-right: 30px;">
        <table class="form">
            <tr>
                <th class="formTitle"><span class="required">*</span>名称：</th>
                <td class="formValue">
                    <input id="zdmc" name="zdmc" type="text" class="form-control required" placeholder="请输入名称" />
                </td>
            </tr>
            <tr>
                <th class="formTitle"><span class="required">*</span>编码：</th>
                <td class="formValue">
                    <input id="zdCode" name="zdCode" type="text" class="form-control required" placeholder="请输入编码" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">诊断类型：</th>
                <td class="formValue formDdlSelectorTd">
                    <select id="zdlx" name="zdlx" class="form-control">
                        <option value="">==请选择==</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th class="formTitle">ICD10：</th>
                <td class="formValue">
                    <input id="icd10" name="icd10" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">ICD10附加码：</th>
                <td class="formValue">
                    <input id="icd10fjm" name="icd10fjm" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle"><span class="required">*</span>首拼：</th>
                <td class="formValue">
                    <input id="py" name="py" type="text" class="form-control required" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">五笔：</th>
                <td class="formValue">
                    <input id="wb" name="wb" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">排序：</th>
                <td class="formValue">
                    <input id="px" name="px" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle" style="height: 35px;">状态：</th>
                <td class="formValue" style="padding-top: 1px;">
                    <div class="ckbox">
                        <input id="zt" name="zt" type="checkbox" checked="checked"><label for="zt">有效</label>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</form>

<script>
    var keyValue = $.request("keyValue");
    $(function () {
        initControl();
        if (!!keyValue) {
            $.najax({
                url: "/Settlement/SysDiagnosis/GetFormJson",
                data: { keyValue: keyValue },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                }
            });
        }
        else {
            $.najax({
                url: "/HOME/GetNewFieldUniqueValue?orgIdIsStar=true&topOrgIdIsStar=true&initFieldLength=8&fieldName=xt_zd.zdCode&r=" + Math.random(),
                dataType: "json",
                cache: false,
                success: function (data) {
                    $('#zdCode').val(data.data);
                }
            });
        }
    });

    function initControl() {
        //首拼
        $('#zdmc').keyup(function () {
            $('#py').val($(this).toShouPin());
        });

        //诊断类型
        $("#zdlx").bindSelect({
            url: "/Sys/ItemsData/GetSelectJson",
            param: { code: "DiagnosisType" }
        });
    }

    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }
        var postData = $("#form1").formSerialize();
        $.submitForm({
            url: "/Settlement/SysDiagnosis/SubmitForm?keyValue=" + keyValue,
            param: postData,
            success: function () {
                $.currentWindow().$("#gridList").resetSelection();
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        })
    }
</script>